‫When it comes to the eve lecture and in this lecture, we are now going to be starting adding items
‫to our to our database, using our API.
‫So if you have not watched the previous lectures, I would recommend you to strongly go back and watch
‫them so that you are able to catch up with us.
‫So let me come down here and I'm going to do here quickly is I am going to define my function that is
‫going to use to add an item to our database.
‫And then what I'm going to do here is I am going to start writing code that is going to be adding items
‫to our table.
‫Here we have two items as us, as Assad.
‫Now, you can see from our database level we have two items.
‫We, of course, and we have this other thing.
‫And from our our ERP next instance, the items DOCTYPE has two items.
‫OK, these are just for the purpose of this video.
‫So let's jump into the code quickly.
‫And I'm going to be defining a variable here called add item and I'm going to be equating that to Frappé
‫Dot.
‫So make sure you you type with me so that you understand what this thing is doing.
‫So I'm going to get the document that I want to edit.
‫OK, so this is very important.
‫So document not document but doctype sorry doctype so what you are going to do here when you need to
‫add items instead of Europea next, just get the document that you want to edit and then with from within
‫the document.
‫Of course the document is item and document is code item from within here.
‫Now we can go ahead and tell it what you want to do here.
‫What you want to do is want to do it, add some stuff and I am going to hardcourt this stuff for this
‫for now.
‫And then later in this course, we are going to pass them from our from another application.
‫So we are going to be expecting these things to come so that, for instance, if you are having and
‫mobile up, these items are going to be added inside ERP next from a mobile app.
‫But for this one, I'm going to be recording them here.
‫We are going to see how you're going to expect them there in the next the next year.
‫That is in literature name.
‫So in this one, I want to show you how to had them and send them into a database.
‫So when we come to our instance here, we see that when we click on ADD Item, we have things here that
‫are mandatory.
‫So you cannot save an item inside of this table unless you you add an item code, an item group and
‫the unit of measure.
‫And I'm going to do is I am also going to add an item names a lot of positive looks, looks fancy.
‫All right.
‫So going back to the database level so that we can get the item code, the names that we need in the
‫table in our database is I know this one is item code.
‫So if you are working on a different type of doctor, but you are supposed to do go to the to the database
‫level and see what those things are called, if you do not know how to do that live or if you have not
‫installed, for instance, your ERP next instance, what you need to do is to check from a user from
‫you are from your Tamino here.
‫So let me clear this and get out.
‫Get out completely.
‫I just want to show you how you can you can you can check columns in the table, OCD to Hoppity and
‫then to bench and then from bench.
‫What we need to do is go to Carani is the instance we are working with.
‫And then he began to change my mind about Maria, Maria, Déby, and he said of Maria Debe, and I can
‫do something like describe the table, name is the table.
‫Name is Tab item.
‫I think so.
‫President, yeah, so here we have you have our table, so we have a name, we have agreed that we have
‫all these things we can see item group here.
‫You can see item, name, item group.
‫So what we need to get here.
‫So let's see.
‫Let's go back here.
‫We need the item code.
‫So let's go back here.
‫What is the item code?
‫Let's see.
‫Item code is here so you can copy that.
‫Come with it to your code.
‫Put it here.
‫That is what we had there.
‫So in this one, again, can just do something like X, X, X, X, OK?
‫And then we, we have, um, we need a comma here.
‫We will have another thing that we need to to change.
‫Remember, this is Python, so we need to do proper indentation.
‫The other thing we need to add here is the item name so you can go back and see the item name is this
‫one.
‫So copy that, go back with it here.
‫And I can call this something like fast API item and then comma.
‫And then the next thing that we need from here is the item group.
‫So come back here with the item group is here.
‫Copy that then pasted here and the item group.
‫Remember we have groups already that are set in the in the database.
‫So I'm going to say this is services and then I'm going to have another one which is the default unit
‫of measure.
‫And what is the unit of measure called in this table.
‫Oh, I have broken this.
‫Let me just quit.
‫Rescue is the wanted Skip, so let me just close it and open it again, or you open it again, then
‫I do bench Maria, Maria, Debe.
‫So this one is karani, so I need to do so door to door.
‫So you are up next and then my password is not one.
‫Then I do pity Bench and Karani and then bench Maria DBI.
‫OK, yeah I'm inside of Maria Debe me increase the front of a little bit and now here I can again see
‫describe and this will be Tabar I they Kim.
‫And here, how do I go down here?
‫I cannot go down, but wherever you find how.
‫The.
‫I got.
‫And then the other thing is the default unit of measure, and we can see from here that we have stock
‫you this is autisms that the default use of measure, unit of measure, put it here.
‫And this one, I'm going to say that the unit of measure here is unit, OK?
‫And then once that is done, then we need not to set this thing up to our database.
‫So we need to save it now to a database.
‫And how we do that, we see the variable put.
‫In my case, it is at item dot.
‫Don't insult.
‫And this is going to be insulting to the database, but to confirm, just do Frappier DOD just to make
‫sure that DBE don't commit could probably be commit.
‫This ensures that this thing has been stuffed into the database.
‫All right.
‫So this is our function.
‫Let's let's send it.
‫I hope that you know what is going to happen here, so let's try and send it.
‫I hope you have already guessed what's going to happen.
‫We are we are going to call this function and then if they have that function.
‫After we have we want to call this function and then if they have called this function, what we're
‫going to do is we are going to go ahead and insert an item into a database so it can backfire and reload
‫our table.
‫And we have two items here.
‫So what do you think is going to happen?
‫So first of all, open will open another window and another tabone on.
‫You are on you are on your posthuman.
‫And then I can just copy this and put it here.
‫But of course, remember, this last method is not going to be that, because if you run, this idea
‫is going to get two items.
‫What I want to do is to call the add item method.
‫When I send that, of course, there's going to be a problem and it is telling you that you do not have
‫permission to do that.
‫Reason is because, like you guessed it, we do not adhere frappé.
‫Dot, wait.
‫OK, so we had not waitlisted listed our method here, so it's not going to work.
‫So let me see again.
‫Do you think this is going to work.
‫Let's test it with our postman.
‫Send it.
‫And no, it is not going to result because this is not a public API.
‫Remember here we we had to send this as a public API.
‫This is not a public API.
‫So what you need to do here is supply allergist's, which is true, which I do not think I'm going to
‫do.
‫I am going to set this thing as a protected DPA.
‫So I'm going to do in this one.
‫I am going to send my authorization token for this one.
‫So go to the headers other key authorization
‫authorization and paste your key here and then send in year.
‫You have gotten some empty object and that is because we have not returned anything.
‫If you check our code, we have not ordered to done anything.
‫So when you come here and you refresh this, yes, you have API appetitive.
‫So this one has been added from our API.
‫If you need to return something, of course we need to return as our message.
‫We can just return
‫whatever you can just standard variable and that is it.
‫So if you go back here now and maybe do y y y y and we do a second item and this is a service and that
‫that's OK, we can go back here and send and I realized that this one has returned us.
‫This is way, way, way, way and all the details of that item.
‫And yes, when you come back to our ERP instance, we see that we have our second item.
‫So this is an EPA that is working, but it cannot be consumed by a mobile app.
‫That is because these things are hard coded.
‫So in the next election, I am going to be showing you how to get these things from my mobile app all
‫the way above.
‫That is done with using using something like react like if you like, and you don't in any other front
‫end technology that you are using.
‫So thank you so much and see you in the next lecture.